<template>
	<view class="coupon">
		<view class="coupon-bg">
			<image src="https://coach-vehicle-uat-1313990257.cos.ap-beijing.myqcloud.com/miniapp/mine/coupon_bg_detail.png"></image>
		</view>
		
		<view class="coupon-content">
			<view class="navbar" :style="{ paddingTop: systemBarHeight + 'px' }">
				<uni-nav-bar left-icon="left" title="优惠券" color="#ffffff" backgroundColor="transparent" :border="false" @clickLeft="back"/>
			</view>
			
			<view class="info">
				<text>{{ info.distributionChannelText }}</text>
				<text>¥{{ info.denomination }}</text>
				<view>{{ info.instructions || ''}}</view>
			</view>
			
			<view class="box">
				<view>• 适用平台：<text>{{ info.commodityType === '0' ? '全部轮胎' : '指定轮胎'}}</text></view>
				<view>• 有效期至：<text>{{ info.couponEndTime ? info.couponEndTime.slice(0,11) : '' }}</text></view>
				<view class="box-note">• 详细说明：<text>{{ info.displayName || '' }}</text></view>
			</view>
		</view>
		
		<view class="coupon-bottom">
			<u-button text="立即使用" color="#CF1A1B" @click="handleUse"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				systemBarHeight: 0, // 系统状态栏的高度
				info: {}
			};
		},
		onLoad: function (option) { 
			this.info = JSON.parse(option.data)
			this.getSysteminfo()
		},
		methods: {
			// 获取系统栏高度
			getSysteminfo() {
				uni.getSystemInfo({
					success: res => {
						this.systemBarHeight = res.statusBarHeight;
					}
				});
			},
			back() {
				uni.navigateBack()
			},
			handleUse () {
				uni.navigateTo({
					url: `/components/goodsList?index=hlt`
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.coupon {
	width: 100%;
	height: 100%;
	box-sizing: border-box;
	
	&-bg {
		height: 300px;
		width: 100%;
		position: absolute;
		z-index: 1;
		image {
			width: 100%;
			height: 100%;
		}
	}
	&-content {
		z-index: 99;
		height: 100%;
		position: relative;
		.navbar {
			/deep/ .uni-icons {
				font-size: 24px !important;
			}
		}
		.info {
			height: 180px;
			display: flex;
			flex-direction: column;
			align-items: center;
			color: #FFFFFF;
			text {
				&:nth-child(1) {
					font-size: 36rpx;
					line-height: 40px;
				}
				&:nth-child(2) {
					font-size: 82rpx;
					font-weight: bold;
				}
			}
			view {
				height: 80px;
				font-size: 28rpx;
				padding: 0 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
		.box {
			height: 145px;
			background-color: #FFFFFF;
			border-radius: 12rpx;
			margin: 0 20rpx;
			padding: 0 40rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-evenly;
			font-size: 28rpx;
			color: rgba(0,0,0,0.85);
			&-note {
				display: flex;
				text {
					flex: 1;
					word-break: break-all;
				}
			}
		}
		
	}
	
	&-bottom {
		height: 70px;
		width: 100%;
		z-index: 99;
		position: absolute;
		bottom: 0;
		display: flex;
		align-items: center;
		justify-content: center;
		background-color: #FFFFFF;
		/deep/ .u-button {
			width: 90% !important;
		}
	}
}
</style>
